package main

import "fmt"

type Boy struct {
	name string
}

//类型判断
func main() {
	i := make([]interface{}, 4)
	i[0] = 1
	i[1] = "abc"
	i[2] = Boy{"tom"}
	i[3] = &Boy{"bob"}
	for index, data := range i {
		switch val := data.(type) {
		case int:
			fmt.Println("i=", index, " int :", val)
		case string:
			fmt.Println("i=", index, " string :", val)
		case Boy:
			fmt.Println("i=", index, " Boy :", val)
		case *Boy:
			fmt.Println("i=", index, " *Boy :", val)
		}
	}
}
